<?php
@include('include/common.inc.php');	
@include('logincleck.php');	
$mem_id = $_SESSION['mem_id'];
$sel = "select * from $TBL_MEM where user_id ='$mem_id'";
$res = mysql_query($sel);
$row = mysql_fetch_array($res);
if($row['sex']=='男')
{	
	$sex = "<INPUT name=sex type=radio class='input2' value=男 checked>  男	 　 
			<INPUT name=sex type=radio class='input2' value=女>女";	
}else{
	$sex = "<INPUT name=sex type=radio class='input2' value=男 > 男　 
			<INPUT name=sex type=radio class='input2' value=女 checked>女";	
}
$id = $row['id'];
$user_id = $row["user_id"];
$name = $row["name"];
$birth = $row["birth"];
$profession = $row["profession"];
$mobile = $row["mobile"];
$email = $row["email"];
$idk = $row["idk"];
$tel = $row["tel"];
$addr = $row["addr"];
if($_POST['type'])
{		
	$name = work_str($_POST["name"], 1);
	$sex = work_str($_POST["sex"], 1);			
	$mobile = work_str($_POST["mobile"], 1);		
	$birth = work_str($_POST["birth"], 1);	
	$job = work_str($_POST["job"], 1);
	$email = work_str($_POST["email"], 1);
	$idk = work_str($_POST["idk"], 1);
	$tel = work_str($_POST["tel"], 1);
	$addr = work_str($_POST["addr"], 1);
	if($_POST['idk']=='')
	{
		$sel = "select * from $TBL_MEM where (mobile='$mobile' and user_id!='$mem_id') or (email ='$email' and user_id!='$mem_id')";	
	}else{
		$sel = "select * from $TBL_MEM where (mobile='$mobile' and user_id!='$mem_id') or (idk='$idk'  and user_id!='$mem_id') or (email ='$email' and user_id!='$mem_id')";			
	}
	$result = mysql_query($sel);
	if(mysql_fetch_array($result))
	{
			 MyNotice("該賬戶，郵箱，身份證，手機已經被注冊", 1, "news.php");
	}else{
		$update = "update $TBL_MEM set name='$name',sex='$sex',mobile='$mobile',birth='$birth',profession='$job',email='$email',idk='$idk',tel='$tel',addr='$addr' where user_id='$mem_id'";
		if(mysql_query($update))
		{
			MyNotice("Success!", 2, "member.php");
			exit();
		}else{
			MyNotice("Sorry!", 2, "member.php");
			exit();
		}
	}
}

$selxx1 = "select * from $TBL_OPTION where type=10 order by ord asc";
$resxx1 = mysql_query($selxx1);	
while($rowxx1 = mysql_fetch_array($resxx1))
{
   $jobb = $jobb ."<OPTION value=$rowxx1[title]>".$rowxx1[title]."</OPTION>";
}
$smarty->assign("jobb",$jobb);
$smarty->assign("user_id",$user_id);
$smarty->assign("name",$name);
$smarty->assign("sex",$sex);	
$smarty->assign("birth",$birth);
$smarty->assign("profession",$profession);
$smarty->assign("mobile",$mobile);
$smarty->assign("email",$email);
$smarty->assign("idk",$idk);
$smarty->assign("tel",$tel);
$smarty->assign("addr",$addr);
@include('number.php');//验证码
$smarty->display('userinfo.html');
?>